import {
  exportUrl,
  getModelingList
} from '@/api/barcodeprint/mesProdBarcodeReprint'
import { getDict } from '@/api/common'

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t('common.export'),
    type: 'primary',
    icon: 'el-icon-download',
    handleName: 'export', // 点击时返回的标识
    url: exportUrl
    // auth: 'auth:operlog:export', // 权限字段
  }
  // {
  //   name: '新增',
  //   type: 'primary',
  //   icon: 'el-icon-circle-plus-outline',
  //   handleName: 'add', //点击时返回的标识
  // },
  // {
  //   name: '删除',
  //   type: 'danger',
  //   icon: 'el-icon-delete',
  //   handleName: 'deleteBatch', //点击时返回的标识
  //   isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  // },
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t('mesProdBarcodeReprint.examine'),
    type: 'danger',
    class: 'row-btn-danger',
    handleName: 'examine'
  }
]

// 搜索条件配置
export const searchConfig = {
  data() {
    const _this = this
    return {
      searchConfig: {
        inline: true,
        formDesc: {
          orderCode: {
            type: 'input',
            label: _this.$i18n.t('mesProdBarcodeReprint.orderCode')
          },
          prodCode: {
            type: 'input',
            label: _this.$i18n.t('mesProdBarcodeReprint.prodCode')
          },
          prodName: {
            type: 'input',
            label: _this.$i18n.t('mesProdBarcodeReprint.prodName')
          },
          planBeginDate: {
            type: 'daterange',
            label: _this.$i18n.t('mesProdBarcodeReprint.planBeginDate'),
            attrs: {
              valueFormat: 'yyyy-MM-dd',
              searchArrKey: ['planBeginDateMin', 'planBeginDateMax']
            }
          },
          workshopCode: {
            type: 'select',
            label: _this.$i18n.t('common.workshopName'),
            prop: {
              value: 'modelingCode',
              text: 'modelingName'
            },
            options: async (data) => {
              const params = {
                modelingCode: _this.$store.getters.factoryCode,
                level: 4
              }
              const list = await getModelingList(params)
              return list.data.result
            }
          },
          lineCode: {
            type: 'select',
            label: _this.$i18n.t('common.lineName'),
            disabled: (data) => {
              return data.workshopCode ? false : true
            },
            optionsLinkageFields: ['workshopCode'],
            prop: {
              value: 'modelingCode',
              text: 'modelingName'
            },
            options: async (data) => {
              if (data.workshopCode) {
                const params = {
                  modelingCode: data.workshopCode,
                  level: 5
                }
                const list = await getModelingList(params)
                return list.data.result
              } else {
                return []
              }
            }
          },
          status: {
            type: 'select',
            label: _this.$i18n.t('common.status'),
            prop: {
              value: 'value',
              text: 'description'
            },
            options: async (data) => {
              const list = await getDict('mes_barcode_reprint_status')
              return list.data.result
            }
          },
          isPrint: {
            type: 'select',
            label: _this.$i18n.t('mesProdBarcodeReprint.isPrint'),
            prop: {
              value: 'value',
              text: 'description'
            },
            options: async (data) => {
              const list = await getDict('yes_or_not')
              return list.data.result
            }
          },
          createTime: {
            type: 'daterange',
            label: _this.$i18n.t('mesProdBarcodeReprint.createTime'),
            attrs: {
              valueFormat: 'yyyy-MM-dd HH:mm:ss',
              searchArrKey: ['createTimeMin', 'createTimeMax']
            }
          }
        }
      }
    }
  }
}
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    orderCode: {
      type: 'input',
      label: $i18n.t('mesProdBarcodeReprint.orderCode'),
      layout: 12,
      required: false,
      disabled: true
    },
    prodCode: {
      type: 'input',
      label: $i18n.t('mesProdBarcodeReprint.prodCode'),
      layout: 12,
      required: false,
      disabled: true
    },
    prodName: {
      type: 'input',
      label: $i18n.t('mesProdBarcodeReprint.prodName'),
      layout: 12,
      required: false,
      disabled: true
    },
    planBeginDate: {
      type: 'date',
      label: $i18n.t('mesProdBarcodeReprint.planBeginDate'),
      layout: 12,
      required: false,
      attrs: {
        'valueFormat': 'yyyy-MM-dd'
      },
      disabled: true
    },
    workshopName: {
      type: 'input',
      label: $i18n.t('common.workshopName'),
      layout: 12,
      required: false,
      disabled: true
    },
    lineName: {
      type: 'input',
      label: $i18n.t('common.lineName'),
      layout: 12,
      required: false,
      disabled: true
    },
    startBarcode: {
      type: 'input',
      label: $i18n.t('mesProdBarcodeReprint.startBarcode'),
      layout: 12,
      required: false,
      disabled: true
    },
    endBarcode: {
      type: 'input',
      label: $i18n.t('mesProdBarcodeReprint.endBarcode'),
      layout: 12,
      required: false,
      disabled: true
    },
    printTemp: {
      type: 'input',
      label: $i18n.t('mesProdBarcodeReprint.printTemp'),
      layout: 12,
      required: false,
      disabled: true
    },
    examineContent: {
      type: 'textarea',
      label: $i18n.t('mesProdBarcodeReprint.examineContent'),
      layout: 24,
      disabled: false,
      required: true
    }
  }
}
